package com.fanshe;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class ReflectDemo9 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
        // 加载数据
        Properties properties = new Properties();
        FileReader fr = new FileReader("/Users/zhouwei/Desktop/java/java_knowledge/java_learning/java_learning/src/class.txt");
        properties.load(fr);
        fr.close();
        String className = properties.getProperty("className");
        String methodName = properties.getProperty("methodName");

        Class<?> c = Class.forName(className);
        Constructor<?> con = c.getConstructor();
        Object obj = con.newInstance();

        Method m = c.getMethod(methodName);
        m.invoke(obj);
    }
}
